using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._StandardFeatureAnalysisTools._SummarizeData
{
    /// <summary>
    /// <para>Aggregate Points</para>
    /// <para>Uses a layer of point features and a layer of polygon features to determine which points fall within each polygon's area. After determining this point-in-polygon spatial relationship, statistics about all points in the polygon are calculated and assigned to the area.</para>
    /// <para>使用点要素图层和面要素图层来确定哪些点位于每个面的区域内。确定此多边形中的点空间关系后，将计算有关多边形中所有点的统计数据并将其分配给该区域。</para>
    /// </summary>    
    [DisplayName("Aggregate Points")]
    public class AggregatePoints : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public AggregatePoints()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_pointLayer">
        /// <para>Input Points</para>
        /// <para>The point features that will be aggregated into the polygons in the polygon layer.</para>
        /// <para>将聚合到面图层中的面中的点要素。</para>
        /// </param>
        /// <param name="_polygonLayer">
        /// <para>Aggregating Polygons</para>
        /// <para>The polygon features (areas) into which the input points will be aggregated.</para>
        /// <para>输入点将聚合到的面要素（区域）。</para>
        /// </param>
        /// <param name="_outputName">
        /// <para>Output Name</para>
        /// <para>The name of the output layer to create on your portal.</para>
        /// <para>要在门户上创建的输出图层的名称。</para>
        /// </param>
        /// <param name="_keepBoundariesWithNoPoints">
        /// <para>Keep boundaries with no points</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the polygons that have no points within them should be returned in the output.
        ///   <bulletList>
        ///     <bullet_item>Checked—Keep polygons that have no points. This is the default.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—Do not return polygons with no points in the output.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定是否应在输出中返回其中没有点的多边形。
        ///   <bulletList>
        ///     <bullet_item>选中 - 保留没有点的面。这是默认设置。 </bullet_item><para/>
        ///     <bullet_item>未选中 - 不返回输出中不带点的面。</bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// </param>
        public AggregatePoints(object _pointLayer, object _polygonLayer, object _outputName, _keepBoundariesWithNoPoints_value _keepBoundariesWithNoPoints)
        {
            this._pointLayer = _pointLayer;
            this._polygonLayer = _polygonLayer;
            this._outputName = _outputName;
            this._keepBoundariesWithNoPoints = _keepBoundariesWithNoPoints;
        }
        public override string ToolboxName => "Standard Feature Analysis Tools";

        public override string ToolName => "Aggregate Points";

        public override string CallName => "sfa.AggregatePoints";

        public override List<string> AcceptEnvironments => ["extent", "outputCoordinateSystem", "workspace"];

        public override object[] ParameterInfo => [_pointLayer, _polygonLayer, _outputName, _keepBoundariesWithNoPoints.GetGPValue(), _summaryFields, _groupByField, _minorityMajority.GetGPValue(), _percentPoints.GetGPValue(), _aggregatedLayer, _groupSummary];

        /// <summary>
        /// <para>Input Points</para>
        /// <para>The point features that will be aggregated into the polygons in the polygon layer.</para>
        /// <para>将聚合到面图层中的面中的点要素。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Points")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _pointLayer { get; set; }


        /// <summary>
        /// <para>Aggregating Polygons</para>
        /// <para>The polygon features (areas) into which the input points will be aggregated.</para>
        /// <para>输入点将聚合到的面要素（区域）。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Aggregating Polygons")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _polygonLayer { get; set; }


        /// <summary>
        /// <para>Output Name</para>
        /// <para>The name of the output layer to create on your portal.</para>
        /// <para>要在门户上创建的输出图层的名称。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Name")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _outputName { get; set; }


        /// <summary>
        /// <para>Keep boundaries with no points</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the polygons that have no points within them should be returned in the output.
        ///   <bulletList>
        ///     <bullet_item>Checked—Keep polygons that have no points. This is the default.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—Do not return polygons with no points in the output.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定是否应在输出中返回其中没有点的多边形。
        ///   <bulletList>
        ///     <bullet_item>选中 - 保留没有点的面。这是默认设置。 </bullet_item><para/>
        ///     <bullet_item>未选中 - 不返回输出中不带点的面。</bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Keep boundaries with no points")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _keepBoundariesWithNoPoints_value _keepBoundariesWithNoPoints { get; set; }

        public enum _keepBoundariesWithNoPoints_value
        {
            /// <summary>
            /// <para>KEEP_EMPTY</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("KEEP_EMPTY")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>REMOVE_EMPTY</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("REMOVE_EMPTY")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Summary Fields</para>
        /// <para><xdoc>
        ///   <para>A list of field names and statistical summary type that you wish to calculate for all points within each polygon. The count of points within each polygon is always returned. The following statistic types are supported:
        ///   <bulletList>
        ///     <bullet_item>Sum—The total value.  </bullet_item><para/>
        ///     <bullet_item>Minimum—The smallest value.  </bullet_item><para/>
        ///     <bullet_item>Max—The largest value.  </bullet_item><para/>
        ///     <bullet_item>Mean—The average or mean value.  </bullet_item><para/>
        ///     <bullet_item>Standard deviation—The standard deviation.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>要为每个面内的所有点计算的字段名称和统计汇总类型的列表。始终返回每个多边形内的点数。支持以下统计信息类型：
        ///   <bulletList>
        ///     <bullet_item>Sum - 总值。</bullet_item><para/>
        ///     <bullet_item>最小值 - 最小值。</bullet_item><para/>
        ///     <bullet_item>Max - 最大值。</bullet_item><para/>
        ///     <bullet_item>均值 - 平均值或平均值。</bullet_item><para/>
        ///     <bullet_item>标准差 （Standard deviation） - 标准差。</bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Summary Fields")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _summaryFields { get; set; } = null;


        /// <summary>
        /// <para>Group By Field</para>
        /// <para><xdoc>
        ///   <para>A field name in the pointLayer. Points that have the same value for the group by field will have their own counts and summary field statistics.</para>
        ///   <para>You can create statistical groups using an attribute in the analysis layer. For example, if you are aggregating crimes to neighborhood boundaries, you may have a Crime_type attribute with five different crime types. Each unique crime type forms a group, and the statistics you choose will be calculated for each unique value of Crime_type. When you choose a grouping attribute, two results are created: the result layer and a related table containing the statistics.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>pointLayer 中的字段名称。对字段分组具有相同值的点将具有自己的计数和汇总字段统计数据。</para>
        ///   <para>您可以使用分析图层中的属性创建统计组。例如，如果要将犯罪聚合到邻域边界，则可能具有具有五种不同犯罪类型的Crime_type属性。每种独特的犯罪类型都会形成一个组，您选择的统计数据将针对每个 Crime_type 的唯一值进行计算。选择分组属性时，将创建两个结果：结果图层和包含统计数据的相关表。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Group By Field")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _groupByField { get; set; } = null;


        /// <summary>
        /// <para>Add minority and majority attributes</para>
        /// <para><xdoc>
        ///   <para>This Boolean parameter is applicable only when a Group By Field is specified. If checked, the minority (least dominant) or the majority (most dominant) attribute values for each group field within each boundary are calculated. Two new fields are added to the output layer prefixed with Majority_ and Minority_.
        ///   <bulletList>
        ///     <bullet_item>Unchecked—Do not add minority and majority fields. This is the default.  </bullet_item><para/>
        ///     <bullet_item>Checked—Add minority and majority fields.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>仅当指定了“分组依据”字段时，此布尔参数才适用。如果选中该选项，则将计算每个边界内每个组字段的少数（最主要）或多数（最主要）属性值。两个新字段将添加到以 Majority_ 和 Minority_ 为前缀的输出图层。
        ///   <bulletList>
        ///     <bullet_item>未选中 - 不添加少数和多数字段。这是默认设置。 </bullet_item><para/>
        ///     <bullet_item>选中 - 添加少数和多数字段。</bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Add minority and majority attributes")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _minorityMajority_value _minorityMajority { get; set; } = _minorityMajority_value._false;

        public enum _minorityMajority_value
        {
            /// <summary>
            /// <para>ADD_MIN_MAJ</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("ADD_MIN_MAJ")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_MIN_MAJ</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_MIN_MAJ")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Add percentage</para>
        /// <para><xdoc>
        ///   <para>This Boolean parameter is applicable only when a Group By Field is specified. If checked, the percentage count of points for each unique Group By Field value is calculated. A new field is added to the output group summary table containing the percentages of each attribute value within each group. If Add minority and majority attributes is true, two additional fields are added to the output containing the percentages of the minority and majority attribute values within each group.
        ///   <bulletList>
        ///     <bullet_item>Unchecked—Do not add percentage fields. This is the default.  </bullet_item><para/>
        ///     <bullet_item>Checked—Add percentage fields.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>仅当指定了“分组依据”字段时，此布尔参数才适用。如果选中，则计算每个唯一“按字段分组”值的点数百分比。新字段将添加到输出组汇总表中，其中包含每个组中每个属性值的百分比。如果添加少数和多数属性为 true，则会在输出中添加两个附加字段，其中包含每个组中少数和多数属性值的百分比。
        ///   <bulletList>
        ///     <bullet_item>未选中 - 不添加百分比字段。这是默认设置。 </bullet_item><para/>
        ///     <bullet_item>选中 - 添加百分比字段。</bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Add percentage")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _percentPoints_value _percentPoints { get; set; } = _percentPoints_value._false;

        public enum _percentPoints_value
        {
            /// <summary>
            /// <para>ADD_PERCENT</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("ADD_PERCENT")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_PERCENT</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_PERCENT")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Output Layer</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Layer")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _aggregatedLayer { get; set; }


        /// <summary>
        /// <para>Output Group Layer</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Group Layer")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _groupSummary { get; set; }


        public AggregatePoints SetEnv(object extent = null, object outputCoordinateSystem = null, object workspace = null)
        {
            base.SetEnv(extent: extent, outputCoordinateSystem: outputCoordinateSystem, workspace: workspace);
            return this;
        }

    }

}